package com.bnq.control.common.utils;

import android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;

/**
 * Created by qianwei on 2019/3/19.
 */

public class KeyBoardUtils {

    /**
     * 显示键盘
     *
     * @param view
     */
    public static void showSoftInput(View view) {
        if (null == view) return;
        InputMethodManager imm = (InputMethodManager) view
                .getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        if (null != imm) imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
    }

    /**
     * 隐藏键盘
     */
    public static void hideSoftInput(View view) {
        if (null == view) return;
        InputMethodManager imm = (InputMethodManager) view.getContext()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        if (null != imm) imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }
}
